//实例化Base对象
var $ =function(){
    return new Base();  //每次调用Base都会去new出一个新的对象
}

//声明对象
function Base(){
    //创建一个数组，保存获取的节点和节点数组
    this.elements = [];

    //获取id节点
    this.getId = function(id){
        this.elements.push(document.getElementById(id));
        return this;  //返回Base对象
    }

    //获取元素节点
    this.getTagName = function(tag){
        //声明一个数组，保存获取的元素节点
        var tags = document.getElementsByTagName(tag);
        for(var i=0;i<tags.length;i++){
            this.elements.push(tags[i]);
        }

        return this;

    }
}

//对象属性css
Base.prototype.css = function(attr,value){
    for(var i=0;i<this.elements.length;i++){
        this.elements[i].style[attr] = value;
    }
    
    return this;
}

//对象属性html
Base.prototype.html = function(str){
    for(var i=0;i<this.elements.length;i++){
        this.elements[i].innerHTML = str;
    }
    return this;
}

//对象属性onlick
Base.prototype.click = function(fn){
    for(var i=0;i<this.elements.length;i++){
        this.elements[i].onclick = fn;
    }
    return this;
}
